<!DOCTYPE html>
<html class="x-admin-sm">
{include file="common/static" /}
    <body>
        <div class="layui-fluid">
            <div class="layui-row">
                <form class="layui-form">

                    <div class="layui-form-item">
                        <label for="username" class="layui-form-label">
                            <span class="x-red">*</span>商品模型</label>
                        <div class="layui-input-inline">
                            <select name="shipping" class="valid" id="goods_id">

                                {volist name='list' id='v'}
                                <option value="{$v.id}">{$v.name}</option>
                                {/volist}

                            </select>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label for="username" class="layui-form-label">
                            <span class="x-red">*</span>商品数量
                        </label>
                        <div class="layui-input-inline">
                            <input type="text" id="number" name="username" required="" lay-verify="required"
                                   autocomplete="off" class="layui-input">
                        </div>
                    </div>
                        <input type="hidden" id="order_id" value="{$id}">


                  <div class="layui-form-item">
                      <label for="L_repass" class="layui-form-label">
                      </label>
                      <button  class="layui-btn" type="button" onclick="adds()">
                          增加
                      </button>
                  </div>
              </form>
            </div>
        </div>

    </body>
<script>
    layui.use(['form', 'layer'],
            function() {
                $ = layui.jquery;
                var form = layui.form,
                        layer = layui.layer;
            });

    function adds(){
        $.ajax({
            type:"post",
            url: "{:url('home/purchase/adds')}",
            data: {
/*                name:$('#name').val(),
                price:$('#price').val(),*/
                id:$('#goods_id').val(),
                number:$('#number').val(),
                order_id:$('#order_id').val()
            },
            success: function(data){
                console.log(data);
                toastr.error(data.msg);
                if(data.code == 100){
                    setTimeout(function () {
                        layer.closeAll();
                        parent.location.reload();
                    },1500);
                }
            }});
    }

</script>
</html>
